#include <iostream>
#include <algorithm>
#include <cmath> 
using namespace std;

const unsigned N = 1e5 + 10;
unsigned school[N];
unsigned student[N];

int main() {
    unsigned m, n;
    cin >> m >> n;

    for (unsigned i = 0; i < m; i++) cin >> school[i];
    for (unsigned i = 0; i < n; i++) cin >> student[i];

    sort(school, school + m);

    unsigned long long sum = 0;

    for (unsigned i = 0; i < n; i++) {
        auto it = lower_bound(school, school + m, student[i]);

        unsigned diff1 = (it != school) ? student[i] - *(it - 1) : UINT_MAX;
        unsigned diff2 = (it != school + m) ? *it - student[i] : UINT_MAX;

        sum += min(diff1, diff2);
    }

    cout << sum << endl;
    return 0;
}